#include "radar_cat240_uploder.h"

RadarCat240Uploader::RadarCat240Uploader(boost::asio::io_service &service)
    :udp_send_(service)
{
    init();
}

RadarCat240Uploader::~RadarCat240Uploader()
{
    summary_timer_.stop();
}

void RadarCat240Uploader::init()
{
    communication_para para;
    para.init();

    std::string ip = "100.100.2.254";
    int port = 15000;

    para.just_send = true;
    para.udp_send_ip = ip;
    para.udp_send_port = port;

    udp_send_.Open(para);

    summary_timer_.setInterval(std::bind(&RadarCat240Uploader::send_video_summary, this), 1000);
}

void RadarCat240Uploader::send_msg(const std::string &msg)
{
    udp_send_.SendMsg(msg);
}

void RadarCat240Uploader::video_data_callback(void *data)
{
    Cat240Data *cat_240_data = (Cat240Data *)data;

    send_msg(cat240_ver103_.OriginalPackMessage(*cat_240_data));
}

void RadarCat240Uploader::send_video_summary()
{
    send_msg(cat240_ver103_.CambridgeVideoSummary());
}